﻿using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;

namespace BCCServer.Model.Models
{
    public partial class bccContext : DbContext
    {
        public bccContext()
        {
        }

        public bccContext(DbContextOptions<bccContext> options)
            : base(options)
        {
        }

        public virtual DbSet<SCommodity> SCommodities { get; set; } = null!;
        public virtual DbSet<SCommodityorder> SCommodityorders { get; set; } = null!;
        public virtual DbSet<SShoppingcart> SShoppingcarts { get; set; } = null!;
        public virtual DbSet<SUser> SUsers { get; set; } = null!;
        public virtual DbSet<UChatinfo> UChatinfos { get; set; } = null!;
        public virtual DbSet<UFriend> UFriends { get; set; } = null!;
        public virtual DbSet<UUser> UUsers { get; set; } = null!;

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            if (!optionsBuilder.IsConfigured)
            {
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see http://go.microsoft.com/fwlink/?LinkId=723263.
                optionsBuilder.UseMySql("server=localhost;port=3306;user=root;password=123456;database=bcc", Microsoft.EntityFrameworkCore.ServerVersion.Parse("8.0.28-mysql"));
            }
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.UseCollation("utf8mb4_0900_ai_ci")
                .HasCharSet("utf8mb4");

            modelBuilder.Entity<SCommodity>(entity =>
            {
                entity.ToTable("s_commodity");

                entity.HasComment("商品表");

                entity.Property(e => e.CreateTime)
                    .HasColumnType("datetime")
                    .HasComment("创建时间");

                entity.Property(e => e.Creater)
                    .HasMaxLength(255)
                    .HasComment("创建人");

                entity.Property(e => e.ImageAddress)
                    .HasMaxLength(500)
                    .HasComment("图片地址");

                entity.Property(e => e.InventoryQuantity).HasComment("库存数量");

                entity.Property(e => e.IsDelete).HasComment("是否删除1是0否");

                entity.Property(e => e.Name)
                    .HasMaxLength(100)
                    .HasComment("名称");

                entity.Property(e => e.Price)
                    .HasPrecision(10, 2)
                    .HasComment("价格");

                entity.Property(e => e.SalesQuantity).HasComment("销售数量");

                entity.Property(e => e.StoreName)
                    .HasMaxLength(255)
                    .HasComment("店铺名称");

                entity.Property(e => e.SuserId)
                    .HasColumnName("SUserId")
                    .HasComment("商家用户id");

                entity.Property(e => e.Title)
                    .HasMaxLength(255)
                    .HasComment("标题");

                entity.Property(e => e.UpdateTime)
                    .HasColumnType("datetime")
                    .HasComment("修改时间");
            });

            modelBuilder.Entity<SCommodityorder>(entity =>
            {
                entity.ToTable("s_commodityorder");

                entity.Property(e => e.CommodityId).HasComment("商品Id");

                entity.Property(e => e.CommodityNum).HasComment("商品数量");

                entity.Property(e => e.CreateTime).HasColumnType("datetime");

                entity.Property(e => e.Creater).HasMaxLength(255);

                entity.Property(e => e.IsDelete).HasComment("是否删除1是0否");

                entity.Property(e => e.IsPayment).HasComment("是否付款");

                entity.Property(e => e.SuserId)
                    .HasColumnName("SUserId")
                    .HasComment("商城用户Id");

                entity.Property(e => e.UpdateTime).HasColumnType("datetime");
            });

            modelBuilder.Entity<SShoppingcart>(entity =>
            {
                entity.ToTable("s_shoppingcart");

                entity.HasComment("购物车表");

                entity.Property(e => e.CommodityId).HasComment("商品Id");

                entity.Property(e => e.CommodityNum).HasComment("商品数量");

                entity.Property(e => e.CreateTime).HasColumnType("datetime");

                entity.Property(e => e.Creater).HasMaxLength(255);

                entity.Property(e => e.SuserId)
                    .HasColumnName("SUserId")
                    .HasComment("商城用户Id");

                entity.Property(e => e.UpdateTime).HasColumnType("datetime");
            });

            modelBuilder.Entity<SUser>(entity =>
            {
                entity.ToTable("s_user");

                entity.HasComment("商城用户表");

                entity.Property(e => e.CreateTime)
                    .HasColumnType("datetime")
                    .HasComment("创建时间");

                entity.Property(e => e.Creater)
                    .HasMaxLength(255)
                    .HasComment("创建人");

                entity.Property(e => e.IsDelete).HasComment("是否删除1是0否");

                entity.Property(e => e.Name)
                    .HasMaxLength(50)
                    .HasComment("商城用户名称");

                entity.Property(e => e.Telephone)
                    .HasMaxLength(50)
                    .HasComment("电话");

                entity.Property(e => e.Type).HasComment("1商家2普通用户");

                entity.Property(e => e.UpdateTime)
                    .HasColumnType("datetime")
                    .HasComment("修改时间");

                entity.Property(e => e.UserId).HasComment("用户id");
            });

            modelBuilder.Entity<UChatinfo>(entity =>
            {
                entity.ToTable("u_chatinfo");

                entity.Property(e => e.CreateTime).HasColumnType("datetime");

                entity.Property(e => e.Info)
                    .HasMaxLength(255)
                    .HasComment("信息");

                entity.Property(e => e.IsDelete).HasComment("是否删除1是0否");

                entity.Property(e => e.ReceiveAccount)
                    .HasMaxLength(50)
                    .HasComment("接收人账号");

                entity.Property(e => e.SendAccount)
                    .HasMaxLength(50)
                    .HasComment("发送人账号");
            });

            modelBuilder.Entity<UFriend>(entity =>
            {
                entity.ToTable("u_friends");

                entity.Property(e => e.Account).HasMaxLength(50);

                entity.Property(e => e.CreateTime).HasColumnType("datetime");

                entity.Property(e => e.Creater)
                    .HasMaxLength(50)
                    .HasComment("创建人");

                entity.Property(e => e.FriendsAccount)
                    .HasMaxLength(50)
                    .HasComment("好友账号");

                entity.Property(e => e.IsDelete).HasComment("0false1true");

                entity.Property(e => e.Relationship).HasComment("1好友2拉黑");

                entity.Property(e => e.UpdateTime).HasColumnType("datetime");

                entity.Property(e => e.Updater)
                    .HasMaxLength(50)
                    .HasComment("修改人");
            });

            modelBuilder.Entity<UUser>(entity =>
            {
                entity.ToTable("u_user");

                entity.Property(e => e.Account)
                    .HasMaxLength(50)
                    .HasComment("账号");

                entity.Property(e => e.Address)
                    .HasMaxLength(255)
                    .HasComment("地址");

                entity.Property(e => e.CreateTime)
                    .HasColumnType("datetime")
                    .HasComment("创建时间");

                entity.Property(e => e.Creater)
                    .HasMaxLength(255)
                    .HasComment("创建人");

                entity.Property(e => e.IsDelete).HasComment("是否删除1是0否");

                entity.Property(e => e.Mail)
                    .HasMaxLength(255)
                    .HasComment("邮箱");

                entity.Property(e => e.Password)
                    .HasMaxLength(50)
                    .HasComment("密码");

                entity.Property(e => e.RoleId).HasComment("角色");

                entity.Property(e => e.Telephone)
                    .HasMaxLength(50)
                    .HasComment("电话");

                entity.Property(e => e.UpdateTime)
                    .HasColumnType("datetime")
                    .HasComment("修改时间");

                entity.Property(e => e.UserName)
                    .HasMaxLength(30)
                    .HasComment("名称");

                entity.Property(e => e.UserSign)
                    .HasMaxLength(100)
                    .HasComment("签名");
            });

            OnModelCreatingPartial(modelBuilder);
        }

        partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
    }
}
